]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
systemActions: Separate CanReboot from CanShutdown
authorAdrian Vovk <adrianvovk@gmail.com>
Tue, 20 Jan 2026 05:04:57 +0000 (00:04 -0500)
committerMarge Bot <marge-bot@gnome.org>
Tue, 3 Mar 2026 04:57:18 +0000 (04:57 +0000)
The reboot actions and shutdown actions are independent, and might have
independent availability. It's perfectly valid for a system
administrator to configure a system where one action is available and
the other isn't. This commit separates the availability of these
actions, and allows them to be independently shown/hidden

There's a corresponding change in gnome-session

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4040>

data/dbus-interfaces/org.gnome.SessionManager.xml
js/misc/systemActions.js

index 74a3a2e558d1a69ef3c4187f6f0cc077ee8771ff..628a4693b1a9411e5b6cfe676bd77b7dbbf547ed 100644 (file)
@@ -8,6 +8,9 @@
     <method name="CanShutdown">
       <arg type="u" direction="out"/>
     </method>
+    <method name="CanReboot">
+      <arg type="u" direction="out"/>
+    </method>
     <method name="IsInhibited">
       <arg type="u" direction="in"/>
       <arg type="b" direction="out"/>
index eb358e37adbfe3fabe2a83d4234c5dab04a05560..8147462178fae1bba3e15c45dfbdd265e4de8cfe 100644 (file)
@@ -83,6 +83,8 @@ const SystemActions = GObject.registerClass({
 
         this._canHavePowerOff = true;
         this._powerOffNeedsAuth = false;
+        this._canHaveReboot = true;
+        this._rebootNeedsAuth = false;
         this._canHaveSuspend = true;
 
         function tokenizeKeywords(keywords) {
@@ -184,11 +186,15 @@ const SystemActions = GObject.registerClass({
         this._lockdownSettings.connect(`changed::${DISABLE_LOCK_SCREEN_KEY}`,
             () => this._updateLockScreen());
 
-        this._lockdownSettings.connect(`changed::${DISABLE_LOG_OUT_KEY}`,
-            () => this._updateHaveShutdown());
+        this._lockdownSettings.connect(`changed::${DISABLE_LOG_OUT_KEY}`, () => {
+            this._updateHaveShutdown();
+            this._updateHaveReboot();
+        });
 
-        this._screenSaverSettings.connect(`changed::${RESTART_ENABLED_KEY}`,
-            () => this._updateHaveShutdown());
+        this._screenSaverSettings.connect(`changed::${RESTART_ENABLED_KEY}`, () => {
+            this._updateHaveShutdown();
+            this._updateHaveReboot();
+        });
 
         this.forceUpdate();
 
@@ -269,6 +275,7 @@ const SystemActions = GObject.registerClass({
     _sessionUpdated() {
         this._updateLockScreen();
         this._updatePowerOff();
+        this._updateReboot();
         this._updateSuspend();
         this._updateMultiUser();
     }
@@ -278,6 +285,7 @@ const SystemActions = GObject.registerClass({
         // settings and Polkit policy - we don't get change notifications for the
         // latter, so their value may be outdated; force an update now
         this._updateHaveShutdown();
+        this._updateHaveReboot();
         this._updateHaveSuspend();
     }
 
@@ -364,8 +372,27 @@ const SystemActions = GObject.registerClass({
                         this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY));
         this._actions.get(POWER_OFF_ACTION_ID).available = this._canHavePowerOff && !disabled;
         this.notify('can-power-off');
+    }
 
-        this._actions.get(RESTART_ACTION_ID).available = this._canHavePowerOff && !disabled;
+    async _updateHaveReboot() {
+        try {
+            const [availability] = await this._session.CanRebootAsync();
+            this._canHaveReboot = availability !== GnomeSession.ActionAvailability.UNAVAILABLE;
+            this._rebootNeedsAuth = availability === GnomeSession.ActionAvailability.CHALLENGE;
+        } catch {
+            this._canHaveReboot = false;
+            this._rebootNeedsAuth = false;
+        }
+        this._updateReboot();
+    }
+
+    _updateReboot() {
+        const disabled = (Main.sessionMode.isLocked &&
+                        !this._screenSaverSettings.get_boolean(RESTART_ENABLED_KEY)) ||
+                       (Main.sessionMode.isLocked && this._rebootNeedsAuth) ||
+                       (Main.sessionMode.isGreeter &&
+                        this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY));
+        this._actions.get(RESTART_ACTION_ID).available = this._canHaveReboot && !disabled;
         this.notify('can-restart');
     }